package com.ruoyi.web.controller.dispatch;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.DispatchWaterQualityQualifiedRateTrendStats;
import com.ruoyi.system.service.IDispatchWaterQualityQualifiedRateTrendStatsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 水质合格率趋势Controller
 * 
 * @author ruoyi
 * @date 2025-03-02
 */
@RestController
@RequestMapping("/system/dispatchWaterQualityQualifiedRateTrendStats")
public class DispatchWaterQualityQualifiedRateTrendStatsController extends BaseController
{
    @Autowired
    private IDispatchWaterQualityQualifiedRateTrendStatsService dispatchWaterQualityQualifiedRateTrendStatsService;

    /**
     * 查询水质合格率趋势列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:list')")
    @GetMapping("/list")
    public TableDataInfo list(DispatchWaterQualityQualifiedRateTrendStats dispatchWaterQualityQualifiedRateTrendStats)
    {
        startPage();
        List<DispatchWaterQualityQualifiedRateTrendStats> list = dispatchWaterQualityQualifiedRateTrendStatsService.selectDispatchWaterQualityQualifiedRateTrendStatsList(dispatchWaterQualityQualifiedRateTrendStats);
        return getDataTable(list);
    }

    /**
     * 导出水质合格率趋势列表
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:export')")
    @Log(title = "水质合格率趋势", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DispatchWaterQualityQualifiedRateTrendStats dispatchWaterQualityQualifiedRateTrendStats)
    {
        List<DispatchWaterQualityQualifiedRateTrendStats> list = dispatchWaterQualityQualifiedRateTrendStatsService.selectDispatchWaterQualityQualifiedRateTrendStatsList(dispatchWaterQualityQualifiedRateTrendStats);
        ExcelUtil<DispatchWaterQualityQualifiedRateTrendStats> util = new ExcelUtil<DispatchWaterQualityQualifiedRateTrendStats>(DispatchWaterQualityQualifiedRateTrendStats.class);
        util.exportExcel(response, list, "水质合格率趋势数据");
    }

    /**
     * 获取水质合格率趋势详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:query')")
    @GetMapping(value = "/{waterQualityQualifiedRateTrendStatsId}")
    public AjaxResult getInfo(@PathVariable("waterQualityQualifiedRateTrendStatsId") Long waterQualityQualifiedRateTrendStatsId)
    {
        return success(dispatchWaterQualityQualifiedRateTrendStatsService.selectDispatchWaterQualityQualifiedRateTrendStatsByWaterQualityQualifiedRateTrendStatsId(waterQualityQualifiedRateTrendStatsId));
    }

    /**
     * 新增水质合格率趋势
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:add')")
    @Log(title = "水质合格率趋势", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DispatchWaterQualityQualifiedRateTrendStats dispatchWaterQualityQualifiedRateTrendStats)
    {
        return toAjax(dispatchWaterQualityQualifiedRateTrendStatsService.insertDispatchWaterQualityQualifiedRateTrendStats(dispatchWaterQualityQualifiedRateTrendStats));
    }

    /**
     * 修改水质合格率趋势
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:edit')")
    @Log(title = "水质合格率趋势", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody DispatchWaterQualityQualifiedRateTrendStats dispatchWaterQualityQualifiedRateTrendStats)
    {
        return toAjax(dispatchWaterQualityQualifiedRateTrendStatsService.updateDispatchWaterQualityQualifiedRateTrendStats(dispatchWaterQualityQualifiedRateTrendStats));
    }

    /**
     * 删除水质合格率趋势
     */
    @PreAuthorize("@ss.hasPermi('system:dispatchWaterQualityQualifiedRateTrendStats:remove')")
    @Log(title = "水质合格率趋势", businessType = BusinessType.DELETE)
	@DeleteMapping("/{waterQualityQualifiedRateTrendStatsIds}")
    public AjaxResult remove(@PathVariable Long[] waterQualityQualifiedRateTrendStatsIds)
    {
        return toAjax(dispatchWaterQualityQualifiedRateTrendStatsService.deleteDispatchWaterQualityQualifiedRateTrendStatsByWaterQualityQualifiedRateTrendStatsIds(waterQualityQualifiedRateTrendStatsIds));
    }
}
